<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.onlineMIS.ORM.entity.chainS.inventoryFlow.ChainInventoryFlowOrder" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<script type="text/javascript" src="<%=request.getContextPath()%>/conf_files/js/inventory/inventory.js?v=1.11"></script>
<script>
var dataGrid ;
$(document).ready(function(){
	parent.$.messager.progress('close'); 	
	loadResult();
	var orderId = $("#orderId").val();
	dataGrid = $('#dataGrid').datagrid({
			url : 'headqInventoryFlowJSONAction!selectOrderProductDetails',
			queryParams: {
				'formBean.flowOrder.id':orderId
			},
            fitColumns: true,
            fit: true,
            singleSelect: true,
            rowStyler: function(index,row){
    			var style = "";
    			if (row.quantity > 10)
    				style += 'color:red;';
    			return style;
    		},
    		showFooter:true,
    		rownumbers:true,
    		editable: false,
            columns: [[
            	
            	{field: 'year', title: '年份', width: 30},
            	{field: 'quarter', title: '季度', width: 30},
            	{field: 'brand', title: '品牌', width: 60},
            	{field: 'categoryLevel', title: '产品线', width: 40},
                {field: 'category', title: '货品类别', width: 60},
            	{field: 'productCode', title: '货号', width: 50},                          
                {field: 'colorName', title: '颜色', width: 40},
                {field: 'barcode', title: '条码', width: 60},
                {field: 'unit', title: '单位', width: 30},                                
                {field: 'salesPrice', title: '零售单价', width: 40},
                {field: 'quantity', title: '纠正数量', width: 40},
                {field: 'totalWholePrice', title: '零售额', width: 50,
    				formatter: function (value, row, index){
    					return row.totalWholePrice.toFixed(2);
    				}},
                {field: 'inventoryQ', title: '库存', width: 40},
                {field: 'comment', title: '摘要', width: 80},
                {field: 'action', title: '图片', width: 30,
        			formatter : function(value, row, index) {
        				if(row.id !=0){
	        				var str = '';     				
	        				str += $.formatString('<a href="#" onclick="viewImgP(\'{0}\');"><img border="0" src="{1}" /></a>', row.barcode,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/img3.png');        			       				
	        				return str;
        				}
        			}},
        		{field: 'scanNums', title: '扫描次数', width: 30},
            ]]});
	
});

//红冲单据  
function cancelOrder(){
	$.messager.confirm('确认', "确认红冲单据", function(r){
		if (r){
			   $.messager.progress({
					text : '数据处理中，请稍后....'
				});		   
			   	var url = "<%=request.getContextPath()%>/action/headqInventoryFlowJSONAction!cancelOrder";
				var params=$("#headqInventoryFlowForm").serialize();  
				$.post(url,params, cancelOrderBackProcess,"json");
		}
	});
}

/**
 * 红冲单据->回调方法
 */
function cancelOrderBackProcess(data){
	$.messager.progress('close');
    var response = data;
	var returnCode = response.returnCode;
	if (returnCode != SUCCESS)
		$.messager.alert('错误', response.message, 'error');
	else {
		$.messager.alert({
			title: '成功',
			closable: false,
			msg: '单据红冲成功！',
			fn: function(){
				parent.closeTab();
			}
		});
    }		
}

function downloadOrder(){
	
    document.headqInventoryFlowForm.action="headqInventoryFlowJSPAction!downloadFlowOrder";
    document.headqInventoryFlowForm.submit();
}

</script>
</head>
<body>
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 130px;">
    <s:form action="/action/headqInventoryFlowJSPAction!editOrder" method="POST" name="headqInventoryFlowForm" id="headqInventoryFlowForm" theme="simple">
	<s:hidden name="formBean.flowOrder.id"/>   
    <table width="98%" align="center"  class="OuterTable">
	    <tr><td>	         
				 <table width="100%" border="0">
				   	 <tr class="PBAOuterTableTitale">
				         <td height="32" colspan="5">
				              	<s:property value="formBean.flowOrder.typeHQS"/>:<s:property value="formBean.flowOrder.id"/>
				         </td>
			           </tr>
				      
				       <tr class="InnerTableContent">
			        
				         <td width="12%"><strong>创建人:&nbsp;   </strong><s:property value="uiBean.flowOrder.creator.name"/></td>
				         <td width="15%"><strong>日期:&nbsp;   </strong><s:property value="uiBean.flowOrder.orderDate"/></td>
				         <td width="40%"><strong>状态: &nbsp;  </strong>
				         	  <s:if test="uiBean.flowOrder.status == 3">
				              		 <font style="color:red"><s:property value="uiBean.flowOrder.statusS"/></font>
				              </s:if><s:else>
				                     <s:property value="uiBean.flowOrder.statusS"/>
				              </s:else>
				         </td>
				         <td>
				         <s:if test="(#session.LOGIN_USER.containFunction('headqInventoryFlowJSPAction!downloadFlowOrder')) ">
				         	<a onclick="downloadOrder();" href="javascript:void(0);" class="easyui-linkbutton c8" style="width:100px; height: 25px;">下载单据</a> 
						 </s:if>
						 <s:if test="(#session.LOGIN_USER.containFunction('headqInventoryFlowJSONAction!cancelOrder')) ">
							<a onclick="cancelOrder();" href="javascript:void(0);" class="easyui-linkbutton c3" style="width:100px; height: 25px;">红冲单据</a> 
				         </s:if>
				         </td>
				       </tr>
				       <tr>
				       		 <td height="35"><strong>仓库: &nbsp;  </strong><s:property value="uiBean.storeName"/></td>
				       		<td  ><strong>备注：</strong><s:property value="uiBean.flowOrder.comment"/></td>
				       		<td colspan="5"></td>
				       </tr>
				     </table></td>
			  </table>
	 </s:form>
	 </div>
	 <div data-options="region:'center',border:false">
		 <table class="easyui-datagrid"  style="width:1320px;height:430px" data-options="singleSelect:true,border : false">			 	
			   <thead>
				 	<tr align="center" class="PBAOuterTableTitale" height="22">
				 		<th data-options="field:'1',width:40">序号</th>
				 		<th data-options="field:'2',width:60">年份</th>	
				 		<th data-options="field:'3',width:60">季度</th>			 					 		
				 		<th data-options="field:'4',width:160">品牌</th>	
				 		<th data-options="field:'17',width:90">产品线</th>
				 		<th data-options="field:'5',width:90">货品类别</th>	
				 		<th data-options="field:'15',width:80">货号</th>
				 		<th data-options="field:'14',width:60">颜色</th>
				 		<th data-options="field:'15',width:80">公司货号</th>	
				 		<th data-options="field:'6',width:90">条码</th>
				 		<th data-options="field:'7',width:40">单位</th>	 				 		
				 		<th data-options="field:'8',width:50">批发单价</th>	
				 		<th data-options="field:'9',width:50">纠正数量</th>		 		
	                    <th data-options="field:'10',width:60">批发总额</th>
	                    <th data-options="field:'11',width:50">库存</th>
	                    <th data-options="field:'12',width:80">摘要</th>			 		
				 		<th data-options="field:'13',width:80" align="center">图片详情</th>
	                </tr>
               </thead>
               <tbody>
               <s:iterator value="uiBean.flowOrder.productList" status = "st" id="order" >
				 	<tr>
				 		<td><s:property value="#st.index+1"/></td>
				 		<td><s:property value="#order.productBarcode.product.year.year"/></td>	
				 		<td><s:property value="#order.productBarcode.product.quarter.quarter_Name"/></td>	
				 		<td><s:property value="#order.productBarcode.product.brand.brand_Name"/> <s:property value="#order.productBarcode.product.brand.comment"/></td>	
				 		<td><s:property value="#order.productBarcode.product.categoryLevel1.category_Name"/></td> 	
				 		<td><s:property value="#order.productBarcode.product.category.category_Name"/></td> 
				 		<td><s:property value="#order.productBarcode.product.productCode"/></td>	
				 		<td><s:property value="#order.productBarcode.color.name"/></td> 
				 		<td><s:property value="#order.productBarcode.product.productIdentity"/></td>
				 		<td><s:property value="#order.productBarcode.barcode"/>
				 		<td><s:property value="#order.productBarcode.product.unit"/></td>			 					 		
				 		<td><s:property value="#order.wholePrice"/></td>	
				 		<td><s:property value="#order.quantity"/></td>
				 		<td><s:property value="#order.totalWholePrice"/></td>	
				 		<td><s:property value="#order.inventoryQ"/></td>	
				 		<td><s:property value="#order.comment"/></td>	
				 		<td><img src="<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/img3.png" border="0" onclick="viewImgP(<s:property value="#order.productBarcode.barcode"/>)"  style="cursor:pointer;"/></td>		 		
				 	</tr>
			 	</s:iterator>
			 	</tbody>
			</table>
	 </div>
</div>		
</body>
</html>